<?php
namespace app\admin\controller;

use app\common\lib\Util;
use app\common\lib\Predis;


class Index
{
    
	
	public function index(){
		echo "1111";
		return "";
	}
	
	public function upimg(){
		
		$file = request()->file('file');
        $info = $file->move('../public/static/upload');
        if($info) {
            $data = [
                'image' => "/upload/".$info->getSaveName(),
            ];
            return Util::show(1, 'OK', $data);
        }else {
            return Util::show(0, 'error');
        }
		
	}
	
	public function push(){
		
		$type = $_GET['type']; // 第几节
		$team_id = $_GET['team_id']; //球队
		$content = $_GET['content'];
		
		
		$teams = [
            1 => [
                'name' => '马刺',
                'logo' => '/live/imgs/team1.png',
            ],
            4 => [
                'name' => '火箭',
                'logo' => '/live/imgs/team2.png',
            ],
        ];
		
		
		$data = [
            'type' => intval($_GET['type']),
            'title' => !empty($teams[$_GET['team_id']]['name']) ?$teams[$_GET['team_id']]['name'] : '直播员',
            'logo' => !empty($teams[$_GET['team_id']]['logo']) ?$teams[$_GET['team_id']]['logo'] : '',
            'content' => !empty($_GET['content']) ? $_GET['content'] : '',
            'image' => !empty($_GET['image']) ? $_GET['image'] : '',
        ];
        //print_r($_GET);
        // 获取连接的用户
        // 赛况的基本信息入库   2、数据组织好 push到直播页面
        $taskData = [
			
            'method' => 'pushLive',
            'data' => $data
        ];
		
		
        $_POST['http_server']->task($taskData);
		
		Util::show(1,"直播成功");
		
	}
	
}
